package com.comut.crud.dao;

import com.comut.crud.pojo.mobile.VehicleInfo;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * Issue: IFL-1571
 *
 * @author celia calcada
 */
public class ReportDao {

    private Connection _connection;

    /**
     * @param connection
     * @param mongodb
     */
    public ReportDao(Connection connection) {
        this._connection = connection;
    }

    /**
     * Issue: IFL-1571
     * @param userId
     * @param language
     * @return 
     */
    public ResultSet getReportsUserId(int userId, String language) {
        // exec [crud].[usp_getReportsForUserId] @userId=332,@language='es'
        HashMap<Integer, VehicleInfo> vehicles = new HashMap();
        CallableStatement statement = null;
        ResultSet resultSet = null;
        String query = "{call [crud].[usp_getReportsForUserId] (?,?)}";
        
        try{
            statement = _connection.prepareCall(query);
            statement.setInt(1, userId);
            statement.setString(2, language);
            resultSet = statement.executeQuery();
        }catch(SQLException ex){
            Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, null, ex);
        }

        return resultSet;
    }
}
